yjx.directive('updateProresult',['$rootScope','$compile','$timeout',function($rootScope,$compile,$timeout){
    return{
        restrict: 'EAC',
        scope: false,
        link: function ($scope, $element, attr) {
            //console.log("this is updateProrsult")
            $scope._updated = false;
            $scope.$watch(attr.updateProresult, function (newVal) {
                $timeout(function () {
                    $scope.addhtml(newVal);
                })
                var html = ''
                $scope.addhtml = function (updated) {
                    //angular.forEach($scope.productList, function (item) {
                    //console.log(updated)
                    //console.log($scope.productList);
                    // html += '<li class="dfr proItem borderB" ng-repeat="item in (productList | orderBy : sortObjectType)" ui-sref="productDetail({id:item.id})" > <div class="proLeft dfc jsc aic"> <div class="proImg2 dfr aic jsc"><img class="w100" ng-src="{{item.avatar}}"></div></div><div class="proRight dfc jssb aifs"> <div class="tProTitle over-hide f14">{{item.title}}</div> <div class="dfr aic jssb w100 c7f"> <div class="dfr"> <div class="priceW" ><span>售价:</span><span>{{item.price?item.price:0}}元</span> </div> <div><span>销量:</span><span>{{item.salesVolume?item.salesVolume:0}}</span> </div> </div>  </div> <div class="dfr aic jssb"> <div class="borkerageW" ng-show="identity == 1"><span class="cred2">健康管理费:{{item.brokerageValue?item.brokerageValue:0}}元</span> </div> <div class="borkerageW" ng-show="identity == 1"><span class="cred2">团队长管理费:{{item.captainBrokerageValue?item.captainBrokerageValue:0}}元</span> </div> </div> </div></li>';
                    html +='<li  class="dfc jssa proItemN " ng-repeat="item in (productList | orderBy : sortObjectType)" ui-sref="productDetail({id:item.id})"> <div class="dfr aic jssb proTop "> <div class="proTopR dfr aic "><span class="proTag {{item.tag==\'新品\'?\'proTagCN\':\'proTagCH\'}} " ng-show="item.tag">{{item.tag}}</span> <span class="over-hide proTitleN">{{item.title}}</span></div> <img class="logoPro" ng-src={{item.avatar}} ng-show="item.avatar" > </div> <div class="c8A proDesc"  ng-show="item.describe">{{item.describe}}</div> <div class="dfr aic proItemB"> <div class="dfr jssb aib w100"> <div class="dfr aib"> <span class="f18 cred2 "><span class="f12">￥</span>{{item.activityPrice?item.activityPrice:item.price}}</span> <span class="orgPrice" ng-show="item.activityPrice">￥{{item.price?item.price:0}}</span> <span class="borkerageW" ng-show="identity == 1">健康管理费:{{item.brokerageValue?item.brokerageValue:0}}元</span></div> <span class="c8A">销量:{{item.salesVolume?item.salesVolume:0}}</span> </div> </div></li>'
                    //});
                    //console.info($scope.mockList)
                    var $html = $compile(html)($scope);
                    $element.html($html);

                }
            })
        }
    }
}])